package com.orientsec.autotest.project.system.targetstruct.controller;

import com.orientsec.autotest.project.system.targetstrucdetail.domain.Targetstrucdetail;
import com.orientsec.autotest.project.system.targetstrucdetail.service.ITargetstrucdetailService;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.orientsec.autotest.framework.aspectj.lang.annotation.Log;
import com.orientsec.autotest.framework.aspectj.lang.enums.BusinessType;
import com.orientsec.autotest.project.system.targetstruct.domain.Targetstruct;
import com.orientsec.autotest.project.system.targetstruct.service.ITargetstructService;
import com.orientsec.autotest.framework.web.controller.BaseController;
import com.orientsec.autotest.framework.web.page.TableDataInfo;
import com.orientsec.autotest.framework.web.domain.AjaxResult;
import com.orientsec.autotest.common.utils.poi.ExcelUtil;

/**
 * 目标文件结构配置信息操作处理
 * 
 * @author autotest
 * @date 2019-12-27
 */
@Controller
@RequestMapping("/system/targetstruct")
public class TargetstructController extends BaseController
{
    private String prefix = "system/targetstruct";
	
	@Autowired
	private ITargetstructService targetstructService;

	@Autowired
	private ITargetstrucdetailService targetstrucdetailService;


	
	@RequiresPermissions("system:targetstruct:view")
	@GetMapping()
	public String targetstruct()
	{
	    return prefix + "/targetstruct";
	}
	
	/**
	 * 查询目标文件结构配置列表
	 */
	@RequiresPermissions("system:targetstruct:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Targetstruct targetstruct)
	{
		startPage();
        List<Targetstruct> list = targetstructService.selectTargetstructList(targetstruct);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出目标文件结构配置列表
	 */
	@RequiresPermissions("system:targetstruct:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Targetstruct targetstruct)
    {
    	List<Targetstruct> list = targetstructService.selectTargetstructList(targetstruct);
        ExcelUtil<Targetstruct> util = new ExcelUtil<Targetstruct>(Targetstruct.class);
        return util.exportExcel(list, "targetstruct");
    }
	
	/**
	 * 新增目标文件结构配置
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存目标文件结构配置
	 */
	@RequiresPermissions("system:targetstruct:add")
	@Log(title = "目标文件结构配置", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Targetstruct targetstruct)
	{		
		return toAjax(targetstructService.insertTargetstruct(targetstruct));
	}

	/**
	 * 修改目标文件结构配置
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		Targetstruct targetstruct = targetstructService.selectTargetstructById(id);
		mmap.put("targetstruct", targetstruct);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存目标文件结构配置
	 */
	@RequiresPermissions("system:targetstruct:edit")
	@Log(title = "目标文件结构配置", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Targetstruct targetstruct)
	{		
		return toAjax(targetstructService.updateTargetstruct(targetstruct));
	}
	
	/**
	 * 删除目标文件结构配置
	 */
	@RequiresPermissions("system:targetstruct:remove")
	@Log(title = "目标文件结构配置", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(targetstructService.deleteTargetstructByIds(ids));
	}



}
